<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        
        
        <button @[ename]="sendCode()">{{msg}}{{num}}秒</button>
    </div>
    <script type="module">
        import { createApp } from "./assets/vue3/vue.esm-browser.js";
        createApp({
            data() {
                return {
                  ename:'click'  ,
                  num:30,
                  msg:"发送验证码"
                }
            },
            methods:{
                sendCode(){
                          console.log(Math.floor(Math.random() * 10000));
                          this.ename=''
                          this.msg='等待'
                         let timer= setInterval(() => {
                            this.num--
                            if(this.num==0){
                                this.ename='click'
                                this.num=30
                                this.msg='发行验证码'
                                clearTimeout(timer)
                            }
                          }, 1000);
                    
                }
            }
        }).mount("#app");
    </script>
</body>
</html>